package com.rbs.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 接口统一返回
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private String code;
    private String message;
    private Object data;

    public static Result success() { //成功无数据返回
        return new Result(Constants.CODE_200, "", null);
    }

    public static Result success(Object data) { //成功有数据返回
        return new Result(Constants.CODE_200, "", data);
    }

    public static Result error(String code, String message) { //有状态码自定义错误返回
        return new Result(code, message, null);
    }

    public static Result error() { //系统默认错误返回
        return new Result(Constants.CODE_500, "系统错误", null);
    }

    //ky测试自用
    public static Result error(String message){return new Result(Constants.CODE_1,message,null);}
}
